<template>
	<view class="">
		<view class="cu-form-group margin-top textareamage">
			
			<textarea  
			 autofocus 
			 maxlength = 25
			 :disabled="modalName!=null"
			 @input="textareaAInput"
			 placeholder="请输入口味,偏好等要求,不支持额外代购其他物品哦~" 
			 :value = 'remarks_val'
			   ></textarea>
		</view>
		<view class="textareaACursorOver">
			<text class="text-gray">{{textareaACursor}}</text>
			<text class="">/25</text>
		</view>
		<view class="cu-form-group">
			<button class='cu-btn bg-green shadow' @click="over">完成</button>
		</view>
	</view>
</template>

<script>
	import { mapState , mapMutations} from 'vuex'
	export default {
		data() {
			return {
				textareaACursor: 0,
				textareaAValue: '',
			}
		},
		computed:{
			...mapState(['remarks_val'])
		},
		methods: {
			...mapMutations(['remarks']),
			textareaAInput(e) {	
					this.textareaAValue = e.detail.value
					this.textareaACursor = e.detail.cursor
					if(this.textareaACursor > 25){
						this.textareaACursor = 25
						uni.showToast({
							icon: 'none',
							title: "已超出字数限制",
						})
					}
			},
			over() {
				this.remarks(this.textareaAValue)
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style>
	page {
		background: #FFFFFF;
	}

	.textareamage {
		margin: 20rpx;
		background-color: #F2F2F2;
		border-radius: 20rpx;
	}

	.textareaACursorOver {
		position: absolute;
		right: 46rpx;
		top: 168rpx;
	}
</style>
